<?php
#header('Content-Type: text/plain');
require_once('inc.config.php');
$json = file_get_contents(JSON_API_SERVER_URL.'/index.php');
#echo $json;

$data = json_decode($json, true);
#print_r($data);
?>
<link href="members.css" type="text/css" rel="stylesheet" />
<div id="members"><!-- empty placeholder --></div>

<!-- full, raw and invisible template -->
<div id="member-template">
	<div class="member">
		<div class="name">{#NAME#}</div>
		<div class="profile"><img src="{#PROFILE#}" alt=""/></div>
	</div>
</div>

<script type="text/javascript">
	// JSON is directly created here from the PHP Array
	var json = <?php echo $json; ?>;

	var html = '';
	var html_unit = '';
	var html_template = document.getElementById('member-template').innerHTML;
	for(var i = 0; i < json.length; ++i)
	{
		html_unit = html_template;
		html_unit = html_unit.replace('{#NAME#}', json[i].name);
		html_unit = html_unit.replace('{#PROFILE#}', json[i].profile);

		html += html_unit;
	}
	document.getElementById('members').innerHTML = html;
</script>